home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / e / sprites / sprites32.e < prev   
Encoding:
Text File  |  1996-09-08  |  2.6 KB  |  81 lines

  1. /* Sprite example
  2. ** --------------
  3. ** This example shows you how to set up a 16 colour AGA sprite with an
  4. ** X axis of 32 pixels.
  5. ** 
  6. ** The sprite is attached to the mouse, so try moving it around a bit.
  7. */
  8.  
  9. MODULE 'games','games/games','exec/memory'
  10.  
  11. PROC main()
  12.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, sparkie:PTR TO sprite,
  13.        zbxy:LONG, timer:LONG
  14.  
  15.    palette := [    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
  16.         $0000,$0688,$0466,$0344,$0CC0,$0980,$0870,$0650,
  17.         $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF,
  18.         $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
  19.           ]:INT;
  20.  
  21.    screen  := [    GSV1,0,              -> GameScreen Version 
  22.         0,0,0,               -> Screen_Mem1,2,3 
  23.         0,                   -> ScreenLink 
  24.         palette,             -> Address of Palette 
  25.         0,                   -> Address of RasterList 
  26.         32,                  -> Amount of colours 
  27.         320,256,             -> Screen Height, Width, Width/8 
  28.         320,256,             -> Pic Height, Width, Width/8 
  29.         1,                   -> Amt_Planes 
  30.         0,0,                 -> Top Of Screen, X/Y 
  31.         0,0,                 -> X/Y pic offsets 
  32.         SPRITES OR NOSPRBDR, -> Special attributes 
  33.         LORES,               -> Screen mode 
  34.         INTERLEAVED,         -> Screen type 
  35.         0,                   -> Screen Is Being Displayed? 
  36.         0                    -> Reserved area 
  37.           ]:gamescreen;
  38.  
  39.    sparkie := [    SPV1,0,         -> Version number
  40.         0,              -> Bank Number 0
  41.         0,              -> Ptr to graphic
  42.         100,100,        -> Beginning X/Y positions
  43.         0,              -> Current frame
  44.         32,21,          -> Width, Height
  45.         16,             -> Amt of colours
  46.         16,             -> Colour start in palette
  47.         2,              -> Amt of planes
  48.         HIRES,          -> Resolution attributes
  49.         0,              -> Position in relation to playfields
  50.         0,0             -> Private
  51.           ]:sprite;
  52.  
  53.  
  54.    IF gmsbase := OpenLibrary('games.library',0)
  55.       SetUserPri()
  56.       IF (Add_Screen(screen) = ERR_OK)
  57.          sparkie.data := SmartLoad('GAMESLIB:data/sparkie32.raw',0,0,MEMF_CHIP)
  58.      Init_Sprite(screen,sparkie)
  59.      Update_Sprite(screen,sparkie)
  60.      Show_Screen(screen)
  61.      zbxy := Read_Mouse(JPORT1)
  62.  
  63.      REPEAT
  64.        IF (timer++ AND $1)
  65.           IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
  66.        ENDIF
  67.        zbxy := Read_Mouse(JPORT1)
  68.        sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
  69.        sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
  70.        Wait_OSVBL()
  71.        Update_Sprite(screen,sparkie)
  72.      UNTIL !(zbxy AND MB_LMB)
  73.  
  74.      FreeMemBlock(sparkie.data);
  75.      Delete_Screen(screen)        
  76.       ENDIF
  77.    CloseLibrary(gmsbase)
  78.    ENDIF
  79. ENDPROC
  80.  
  81.